#!/bin/bash

requestDir=$1

rm hasCmt.res noCmt.res
rm shipit.res noshipit.res

for r in $(ls $requestDir)
do
    shipitCmt=$(grep -i "ship it" ${requestDir}/${r} | wc -l)
    if [ $shipitCmt -gt 0 ];then
        echo $r, "has ship it!", $shipitCmt >>shipit.res
    else
        echo "$r", "has no ship it!", $shipitCmt >> noshipit.res
    fi
    hasCmt=$(grep -E ' class=".*reviewtext .*rich-text.*>' ${requestDir}/${r} | grep -i -v "ship it" | grep -E -v 'rich-text"></pre>' | wc -l)
    if [ $hasCmt -gt 0 ];then
        echo $r, $hasCmt >> hasCmt.res
    else
        echo $r, $hasCmt >> noCmt.res
    fi
done
